package org.doubango.FrCall.Screens;

import org.doubango.FrCall.Engine;
import org.doubango.FrCall.R;
import org.doubango.FrCall.Services.IScreenService;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;

public class ScreenTabSet extends BaseScreen {

	private static String TAG = ScreenTabSet.class.getCanonicalName();
	private IScreenService mScreenService;
	private Button setWap;
	private Button setPageEditButton;
	private Button setPageEditNewMessage;
	private Button setPageEditPrivate;
	private Button setPageShowAbout;
	private Button setPageEditClearMessage;
	private Button exit;
	private WebView wv;
	public ScreenTabSet() {
		super(SCREEN_TYPE.SET_T, TAG);
		System.out.println("ScreenTabSet()");
		mScreenService = ((Engine)Engine.getInstance()).getScreenService();
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.screen_tab_set);
		setWap=(Button) findViewById(R.id.set_to_wap);
		setPageEditButton = (Button) findViewById(R.id.set_edit);
		setPageEditNewMessage = (Button) findViewById(R.id.set_new_message);
		setPageEditPrivate = (Button) findViewById(R.id.set_private);
		setPageShowAbout = (Button) findViewById(R.id.set_about);
		setPageEditClearMessage = (Button) findViewById(R.id.set_clear);
		wv=(WebView) findViewById(R.id.set_web_view);
		exit=(Button) findViewById(R.id.set_exit);
		SetPageButtonListener setPageButtonListener = new SetPageButtonListener();
		setWap.setOnClickListener(setPageButtonListener);
		setPageEditButton.setOnClickListener(setPageButtonListener);
		setPageEditNewMessage.setOnClickListener(setPageButtonListener);
		setPageEditPrivate.setOnClickListener(setPageButtonListener);
		setPageShowAbout.setOnClickListener(setPageButtonListener);
		setPageEditClearMessage.setOnClickListener(setPageButtonListener);
		exit.setOnClickListener(setPageButtonListener);
	}
	public class SetPageButtonListener implements OnClickListener{
		@Override
		public void onClick(View v) {
			if(v==setWap){
				wv.loadUrl("http://club.sohu.com/");
			}else if(v == setPageEditButton){
				mScreenService.show(ScreenPersonalInfo.class);
			}else if(v == setPageEditNewMessage){
				mScreenService.show(ScreenEditNewMessage.class);
			}else if(v == setPageEditPrivate){
				mScreenService.show(ScreenEditPrivate.class);
			}else if(v == setPageShowAbout){
				mScreenService.show(ScreenShowAbout.class);
			}else if(v == setPageEditClearMessage){
				mScreenService.show(ScreenClearMessage.class);
			}else if(v==exit){
				System.exit(0);
			}
		}
		
	}

}
